home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / System 7.0 Samples / AEObject-Edition1.0.2 Sample / Print.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  2.8 KB  |  91 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *  Apple Developer Technical Support
  4.  *
  5.  *  Printing routines
  6.  *
  7.  *  Program:    AEObject-Edition Sample
  8.  *  File:       Print.c -    C Source
  9.  *
  10.  *  by:         C.K. Haun <TR>
  11.  *
  12.  *  Copyright © 1990-1992 Apple Computer, Inc.
  13.  *  All rights reserved.
  14.  *
  15.  *------------------------------------------------------------------------------
  16.  * This file does the printing for this application.  VERY minimal
  17.  *----------------------------------------------------------------------------*/
  18.  
  19. #define __PRINTSTUFF__
  20.  
  21.  
  22.  
  23. #include "Sampdefines.h"
  24. /* prototypes */
  25.  
  26.  
  27. #pragma segment Print
  28.  
  29.  
  30. /* external references */
  31.  
  32. /* PrintIt prints the window passed to it.  The Boolean tells the function */
  33. /* what to do when printing is finished.  This is in place if Print was selected */
  34. /* from the Finder, the window will be closed after it's been printed */
  35. /* and the application will exit */
  36. /* •Note:  As you can see, I don't use the Boolean.  The Finder does what it */
  37. /* should, and quits us itself after a Finder print, so it is no longer necessary */
  38. /* I've left it in here so past users of EditionSample can see why the change was made */
  39.  
  40. void PrintIt(WindowPtr theWind,Boolean bye)
  41. {
  42. #pragma unused(bye)
  43.     THPrint myPrintRec;
  44.     TPPrPort myPrintPort;
  45.     TPrStatus myStats;
  46.     extern Boolean gShowPub;
  47.     extern Boolean gShowSub;
  48.     extern Boolean gShowingAll;
  49.     Boolean temp1, temp2, temp3;
  50.     windowCHandle drawers;
  51.     temp1 = gShowPub;
  52.     temp2 = gShowSub;
  53.     temp3 = gShowingAll;
  54.     gShowPub = gShowSub = gShowingAll = false;
  55.     drawers = (windowCHandle)GetWRefCon(theWind);
  56.     HLock((Handle)drawers);                                 /* lock it down so things don't get stupid */
  57.     PrOpen();
  58.     myPrintRec = (THPrint)NewHandle(sizeof(TPrint));
  59.     PrintDefault(myPrintRec);
  60.     if (PrJobDialog(myPrintRec)) {
  61.         myPrintPort = PrOpenDoc(myPrintRec, nil, nil);
  62.         PrOpenPage(myPrintPort, nil);
  63.         /* jump to the drawing function stored for this window */
  64.         (ProcPtr)((*drawers)->drawMe)(drawers, theWind);
  65.         /* that doesn't draw the text, by the way.  TEUpdate doesn't draw text the way you might think */
  66.         if((*drawers)->boxHandle){
  67.         Handle theText = TEGetText((*drawers)->boxHandle);
  68.         Size theSize = GetHandleSize(theText);
  69.         Rect theRect = (*(*drawers)->boxHandle)->destRect;
  70.         TextFont(monaco);
  71.         TextSize(9);
  72.         HLock(theText);
  73.         TETextBox((Ptr)*theText,theSize,&theRect,0);
  74.         HUnlock(theText);
  75.         
  76.         }
  77.         HUnlock((Handle)drawers);                           /* all done */
  78.         PrClosePage(myPrintPort);
  79.         PrCloseDoc(myPrintPort);
  80.         PrPicFile(myPrintRec, nil, nil, nil, &myStats);
  81.     }
  82.     DisposeHandle((Handle)myPrintRec);
  83.     PrClose();
  84.     gShowPub = temp1;
  85.     gShowSub = temp2;
  86.     gShowingAll == temp3;
  87. }
  88.  
  89.  
  90. #undef __PRINTSTUFF__
  91.